// 引入pinia
import { defineStore } from "pinia";

// 引入请求函数
import { reqGetCategoryList } from "@/api/home";

// 引入ts约束
import type { CategoryListStoreModel } from "@/api/model/homeModel";

// 三级分类
export const useCategoryListStore = defineStore("categoryList", {
  state: (): CategoryListStoreModel => {
    return {
      categoryList: [],
    };
  },
  actions: {
    // 获取三级分类列表
    async getCategoryList() {
      const res = await reqGetCategoryList();
      // console.log("三级分类", res);
      this.categoryList = res;
      // console.log(this.categoryList);
    },
  },
});
